#include <bits/stdc++.h>
using namespace std;
#define int long long
void solve()
{
    int n,m;
    cin>>n>>m;
    vector<int>v(n+1);
    for(int i=1;i<=n;i++)
    {
        cin>>v[i];
    }
    int tmp=0,ans=0;
    bool f=0;
    for(int i=1;i<=n;i++)
    {
        tmp+=v[i];
        if(tmp>m&&f==0)f=1;
        if(tmp<m)ans++;
        else tmp=0;
    }
    if(f)cout<<ans;
    else cout<<-1;
}
signed main()
{
    //ios::sync_with_stdio(false);
    //cin.tie(nullptr);
    int T=1;
    //cin>>T;
    while(T--)
    {
       solve();
    }
    return 0;
}